<template>
  <div class="search-wapper">
    <van-nav-bar
      title="搜索"
      left-text="返回"
      left-arrow
      fixed
      @click-left="onClickLeft"
    >
      <van-icon name="arrow-left" slot="left" />
      <!--<van-icon name="search" slot="right"/>-->
    </van-nav-bar>
    <div class="search-content">
      <van-cell-group>
        <van-field v-model="billid" label="单据编码" placeholder="请输入单据编码" />
<!--        <van-field v-model="empid" label="empid" placeholder="请输入empid" />-->
<!--        <van-field v-model="itemid" label="物资id" placeholder="请输入物资id" />-->
<!--        <van-field-->
<!--          v-model="itemDesc"-->
<!--          label="物资名称"-->
<!--          placeholder="请输入物资名称"-->
<!--        />-->
<!--        <van-field-->
<!--          v-model="itemSpec"-->
<!--          label="物资规格"-->
<!--          placeholder="请输入物资规格"-->
<!--        />-->
<!--		<van-field-->
<!--		  v-model="recvsiteid"-->
<!--		  label="地点"-->
<!--		  placeholder="请输入地点"-->
<!--		/>-->
          <span v-if="status=='I'">
              <van-field
                      v-model="issuecoid"
                      label="劳务队"
                      placeholder="请输入劳务队"
              />
          </span>
<!--          <van-field-->
<!--                  v-model="sitearea"-->
<!--                  label="区域"-->
<!--                  placeholder="请输入区域"-->
<!--          />-->
<!--          </span>-->
          <span v-if="status!='I'">
            <van-field
                    v-model="issuecoid"
                    label="供应商"
                    placeholder="请输入供应商"
            />
          </span>
        <span v-if="status!='M'">
            <van-field
                    v-model="compiler"
                    label="制单人"
                    placeholder="请输入制单人"
            />
          </span>

      </van-cell-group>
    </div>
    <div class="button-content">
      <van-button type="primary" round style="width: 100%" @click="submitInfo"
        >查询</van-button
      >
    </div>
  </div>
</template>

<script>
import { Toast } from "vant";
export default {
  name: "Search",
  data() {
    return {
      userInfo: {},
        status:'',
      show: false,
      billid: "",
      empid: "",
      recvsiteid: "",
      itemid: "",
      itemDesc: "",
      itemSpec: "",
	  comptype:"",
	  issuecoid:"",
        sitearea:"",
      compiler:""
    };
  },
  methods: {
    submitInfo() {
        // eslint-disable-next-line no-empty
        // console.info(this.$route.query.status)
        var status=this.$route.query.status;
        //
        // if(this.billid==""){
        //     this.billid=status;
        // }
        // if(!this.billid.startsWith(status)){
        //     Toast("单据编码错误");
        //     return false;
        // }
        var path="";
        switch (status) {
            case "M":
                path="/items/move";
                break;
            case "A":
                path="/items";
                break;
            case "I":
                path="/items/out";
                break;
            case "R":
                path="/items/enter";
                break;
             default:
                 path="/items";
        }
      this.$router.push({
        path: path,
        query: {
          billid: this.billid,
          recvsiteid: this.recvsiteid,
          issuecoid: this.issuecoid,
            sitearea:this.sitearea,
          compiler:this.compiler
        }
      });
    },
    onClickLeft() {
      this.$router.back(-1);
    }
  },
    created() {
        // console.log(this.$route.query.id)
        this.status = this.$route.query.status;
    }
};
</script>

<style scoped lang="scss">
.search-wapper {
  position: relative;
  .search-content {
    position: relative;
    /*top: 46px;*/
    /*height: calc(100% - 50px);*/
    /*margin-bottom: 10px;*/
    margin: 20px;
    padding: 5px;
    background: #fff;
    border-radius: 8px;
    top: 37%; /*偏移*/
    transform: translateY(-50%);
  }
  .button-content {
    position: relative;
    top: 40%;
    transform: translateY(-50%);
    margin-top: 20px;
    padding: 0px 20px;
  }
}
</style>
